package cn.chengpengper.seckill.activity.infrastructure.repository;

import cn.chengpengper.seckill.activity.domain.model.entity.SeckillActivity;
import cn.chengpengper.seckill.activity.domain.repository.SeckillActivityRepository;
import cn.chengpengper.seckill.activity.infrastructure.mapper.SeckillActivityMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
 * @author chengpeng.hu
 */
@Component
@RequiredArgsConstructor
public class SeckillActivityRepositoryImpl implements SeckillActivityRepository {

    private final SeckillActivityMapper seckillActivityMapper;

    @Override
    public int saveSeckillActivity(SeckillActivity seckillActivity) {
        return seckillActivityMapper.saveSeckillActivity(seckillActivity);
    }

    @Override
    public List<SeckillActivity> getSeckillActivityList(Integer status) {
        return seckillActivityMapper.getSeckillActivityList(status);
    }

    @Override
    public List<SeckillActivity> getSeckillActivityBetweenStartTimeAndEndTime(Date currentTime, Integer status) {
        return seckillActivityMapper.getSeckillActivityBetweenStartTimeAndEndTime(currentTime, status);
    }

    @Override
    public SeckillActivity getSeckillActivityById(Long id) {
        return seckillActivityMapper.getSeckillActivityById(id);
    }

    @Override
    public int updateStatus(Integer status, Long id) {
        return seckillActivityMapper.updateStatus(status, id);
    }
}
